var items = document.getElementsByClassName('item');
var index = 0;
var clearActive = function () {
    for(var i = 0;i<items.length;i++){items[i].className='item'}
}
var goIndx = function () {
    clearActive();
    items[index].className = 'item active'
}

var goNext = function () {
    if(index < 4){
        index  ++;
    }
    else
        index = 0;
        goIndx();
    
}
var goPre = function () {
    if (index == 0) {
        index = 4
    }
    else{
        index --;
    }
    goIndx();
}

var goPreBtn = document.getElementById('left');
var goNextBtn = document.getElementById('right');

goPreBtn.addEventListener('click',function () {
    goPre();
})
goNextBtn.addEventListener('click',function () {
    goNext();
})